<?php
require_once '/home/qss/shupeng/dw/common/lib/ezcomponents/Base/src/ezc_bootstrap.php'; 
require_once '/home/qss/shupeng/dw/executor/workflow/variables/VariableHandler.php'; 

$workflow = new ezcWorkflow('AdhocHiveQuery');

$createHiveTable = new ezcWorkflowNodeAction(array(
    'class' => 'ActivityAction',
    'arguments' =>  array(
        'CreateHiveTable',
    )
));

$filterHiveTable = new ezcWorkflowNodeAction(array(
    'class' => 'ActivityAction',
    'arguments' =>  array(
        'FilterHiveTable',
    )
));

$transfer = new ezcWorkflowNodeSubWorkflow(array(
	'workflow'	=>	'DataXTransfer',
	'variables'	=>	array(
		'in'	=> array(
			'params'	=>	'params',
			'runtimeInfo'	=>	'runtimeInfo',
		),
		'out'	=>	array(
			'runtimeInfo'	=>	'runtimeInfo',
		),
	),
));
/*
$transfer = new ezcWorkflowNodeAction(array(
    'class' => 'ExecutableAction',
    'arguments' =>  array(
        'Transfer',
    )
));
*/

$workflow->startNode->addoutNode($createHiveTable);
$createHiveTable->addOutNode($filterHiveTable);
$filterHiveTable->addOutNode($transfer);
//$createMysqlTable->addOutNode($transfer);
$transfer->addOutNode($workflow->endNode);
$workflow->addVariableHandler('params', 'VariableHandler');

// Set up database connection.
$db = ezcDbFactory::create( 'mysql://dw:dwcloud360@client05v.safe.zzbc.qihoo.net/dw' );

// Set up workflow definition storage (database).
$definition = new ezcWorkflowDatabaseDefinitionStorage( $db );

// Save workflow definition to database.
$definition->save( $workflow );

// Set up workflow definition storage (XML).
//$definition = new ezcWorkflowDefinitionStorageXml( './' );

// Save workflow definition to database.
//$definition->save( $workflow );
